#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from io import BytesIO
from typing import List
from fastapi import APIRouter, File, HTTPException, Query, UploadFile
import pandas as pd

from app.service.userfeedbaclsvc.user_feedback_svc import UserFeedbackService
from app.types.apiproto.user_feedback_proto import (
    FeedbackCreate,
    FeedbackOut,
    FeedbackUpdateStatus,
)
from app.types.apiproto.user_proto import YmUserCreate
from app.dao.user_dao import UserOperateDao, UserQueryDao
from app.service.usersvc.user_list_svc import UserListService
from app.types import apiproto

router = APIRouter(prefix="/feedback", tags=["用户反馈"])


# 学生提交反馈
@router.post("/create", response_model=FeedbackOut)
def submit_feedback(feedback: FeedbackCreate):
    return UserFeedbackService.submit_feedback(feedback)


# 管理员查看所有反馈
@router.get("/list", response_model=list[FeedbackOut])
def list_feedbacks():
    return UserFeedbackService.list_feedbacks()


# 管理员更新反馈状态
@router.patch("/{feedback_id}/status")
def update_feedback_status(feedback_id: str, update: FeedbackUpdateStatus):
    success = UserFeedbackService.update_status(feedback_id, update.status)
    if not success:
        raise HTTPException(status_code=404, detail="反馈未找到")
    return {"message": "状态更新成功"}


# 学生查询自己的反馈记录
@router.get("/student/{student_id}", response_model=list[FeedbackOut])
def get_feedback_by_student(student_id: str):
    return UserFeedbackService.get_feedbacks_for_student(student_id)
